<!-- Tan Phat -->
<?php
	include('class_user.php');
?>
<script type="text/javascript">
// JavaScript Document
var xmlhttp;
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
} 

/*--------------------Phat-------------------*/
//---------------Dang Nhap----------------
function KiemTraDangNhap()
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null )
	{
		alert ("Your browser does not support XML HTTP Request");
		return;
	}
	var n1 = document.getElementById('username').value;
	var n2 = document.getElementById('password').value;
	var n3 = document.getElementById('remember').checked;

	if( n1 == "" || n2 == "" )
	{
		document.location.href = "index.php?com=user&fun=login&Error=1";
	}
	else
	{
		var url ="index.php?com=user&fun=login&Error=0&user=" + n1 + "&pass=" + n2 + "&remember=" + n3;
		url += "&t="+ Math.random();
		document.location.href = url;
	}
}
//-------------------Dang ky---------------------//
function ktuser()
{
	var tendangnhap = document.getElementById("addTenDangNhap").value;
	var loiuser = document.getElementById("loitendangnhap");
	loiuser.style.color = "red";
	if (tendangnhap == "")
	{
		loiuser.innerHTML = "<img src=images/NotOk.gif>";//&nbsp;Không bỏ trống trường bắt buột"  ;
		return false;
	}
	if (tendangnhap.length < 4 )
	{
		loiuser.innerHTML = "<img src=images/NotOk.gif>";//&nbsp;Tên đăng nhập phải lớn hơn 4 kí tự"  ;
		return false;
	}
	var flag =0 ;
	for (var i=0 ; i < tendangnhap.length ; i++)
		if(( tendangnhap[i] < '0' || tendangnhap[i] > '9') && (tendangnhap[i] >'z' || tendangnhap[i] <'a') && (tendangnhap[i] >'Z' || tendangnhap[i] < 'A') )
			flag = 1;
	if(flag ==1)
	{
		loiuser.innerHTML = "<img src=images/NotOk.gif>";//&nbsp;Tên đăng nhập phải gồm kí tự a->z,0->9."  ;
		return false;
	}
	loiuser.innerHTML = "<img src=images/Ok.gif"  ;
	return true;
}

function ktmatkhau1()
{
	var matkhau1 =    document.getElementById("addMatKhau").value;
	var loi = document.getElementById("loimatkhau");
	loi.style.color = "red";
	if(  matkhau1 == "" )
	{
		//loi.innerHTML = "Không bỏ trống trường bắt buột"  ;
		loi.innerHTML = "<img src=images/NotOk.gif>"  ;
		return ;
	}
	if(  matkhau1.length < 6 )
	{
		//loi.innerHTML = "Mật khẩu phải nhiều hơn 6 kí tự" ;
		loi.innerHTML = "<img src=images/NotOk.gif>" ;
		return ;
	}
	//loi.innerHTML = ""  ;
	loi.innerHTML = "<img src=images/Ok.gif>"  ;
}

function ktmatkhau2()
{
	var matkhau1 = document.getElementById("addMatKhau").value;
	var matkhau2 = document.getElementById("addReMatKhau").value;
	var loi = document.getElementById("loairematkhau");
	loi.style.color = "red";
	if(matkhau1 != matkhau2 )
	{
		//loi.innerHTML ="Mật khẩu chưa khớp";
		loi.innerHTML = "<img src=images/NotOk.gif>"  ;
		return ;
	}
	//loi.innerHTML = ""  ;
	loi.innerHTML = "<img src=images/Ok.gif>"  ;
}

function checkEmail(email) 
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) 
		return 0;
	return 1;
}

function ktemailhople()
{
	var email1 =document.getElementById("addEmail").value;
	var loi = document.getElementById("loiemail");
	loi.style.color = "red";
	if(  email1 == "" )
	{
		//loi.innerHTML = "Không bỏ trống trường bắt buột" ;
		loi.innerHTML = "<img src=images/NotOk.gif>"  ;
		return ;
	}
	if( checkEmail(email1) == 0 )
	{
		//loi.innerHTML = "Email không hợp lệ" ;
		loi.innerHTML = "<img src=images/NotOk.gif>"  ;
		return ;
	}
	//loi.innerHTML = ""  ;
	loi.innerHTML = "<img src=images/Ok.gif>"  ;
}

function ktkhopemail()
{
	var email1 =document.getElementById("addEmail").value;
	var email2 =document.getElementById("addReEmail").value;
	var loi = document.getElementById("loireemail");
	loi.style.color = "red";
	if(  email1 != email2 )
	{
		//loi.innerHTML = "Email chưa khớp" ;
		loi.innerHTML = "<img src=images/NotOk.gif>"  ;
		return ;
	}
	//loi.innerHTML = ""  ;
	loi.innerHTML = "<img src=images/Ok.gif>"  ;
}

function kthoten()
{
	var hoten =document.getElementById("addHoTen").value;
	var loi = document.getElementById("loihoten");
	loi.style.color = "red";
	if ( hoten == "" )
	{
		//loi.innerHTML = "Không bỏ trống trường bắt buột" ;
		loi.innerHTML = "<img src=images/NotOk.gif>"  ;
		return ;
	}
//	loi.innerHTML = ""  ;
	loi.innerHTML = "<img src=images/Ok.gif>"  ;
}

function ktdienthoai()
{
	var dienthoai =document.getElementById("addDienThoai").value;
	var loi = document.getElementById("loidienthoai");
	loi.style.color = "red";
	if(isNaN(dienthoai))
	{
		//loi.innerHTML ="Điện thoại phải nhập số" ;
		loi.innerHTML = "<img src=images/NotOk.gif>"  ;
		return;
	}
	if(dienthoai.length>10)
	{
		//loi.innerHTML ="Điện thoại phải nhập số" ;
		loi.innerHTML = "<img src=images/NotOk.gif>"  ;
		return;
	}
	loi.innerHTML = ""  ;
}

function KiemTraCode()
{
	var kq = document.getElementById("ErrorCode");
	var n1 = document.getElementById('security_code').value;
	if( n1 == "" )
	{
		kq.style.color = "red";
		kq.innerHTML = "<img src=images/NotOk.gif>";
		return false;
	}
	else
	{
		kq.innerHTML = "";
		return true;
	}
}

function kttendangnhap(tendangnhap)
{
	if (tendangnhap.length <6 )
		return false ;
	for (var i=0 ; i < tendangnhap.length ; i++)
		if(( tendangnhap[i] < '0' || tendangnhap[i] > '9') && (tendangnhap[i] >'z' || tendangnhap[i] <'a') && (tendangnhap[i] >'Z' || tendangnhap[i] < 'A') )
			return false ;
	return true ;
}

function clearloi()
{
	document.getElementById("loitendangnhap").innerHTML = "" ;
	document.getElementById("loimatkhau").innerHTML = "" ;
	document.getElementById("loairematkhau").innerHTML ="";
	document.getElementById("loiemail").innerHTML = "" ;
	document.getElementById("loireemail").innerHTML ="";
	document.getElementById("loihoten").innerHTML ="";
	document.getElementById("loidienthoai").innerHTML ="";
}

function kiemtradangki()
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null )
	{
		alert ("Your browser does not support XML HTTP Request");
		return;
	}
	clearloi() ;
	
	var ch = document.getElementsByName("checkdangky[]");	
	var IDsLinhvuc = "" ;
	
	for (var i=0 ; i < ch.length ; i++ )
	{
		if ( ch[i].checked == true )
		{
			if( IDsLinhvuc == "" )
				IDsLinhvuc = ch[i].value ;
			else
				IDsLinhvuc += ","+ ch[i].value ;
		}
	}
	
	var tendangnhap =  encodeURI(document.getElementById("addTenDangNhap").value);
	var matkhau1 =  encodeURI(document.getElementById("addMatKhau").value);
	var matkhau2 = encodeURI( document.getElementById("addReMatKhau").value);
	var email1 =  encodeURI(document.getElementById("addEmail").value);
	var email2 =  encodeURI(document.getElementById("addReEmail").value);
	var hoten =  encodeURI(document.getElementById("addHoTen").value);
	var diachi =  encodeURI(document.getElementById("addDiaChi").value);
	var dienthoai = document.getElementById("addDienThoai").value;
	var checkgioitinh = document.getElementById("addGioiTinh").checked;
	
	if(checkgioitinh == true)
		var gioitinh = 1;
	else
		var gioitinh = 0;
	
	var ngay = document.getElementById("ngay").value;
	var thang = document.getElementById("thang").value;
	var nam = document.getElementById("nam").value;
	var ngaysinh = nam +"-"+ thang +"-"+ngay ;
	
	var hinhanh = encodeURI(document.getElementById("addHinhAnh").value);
	if ( hinhanh == "" )
		hinhanh = 'nopic1.gif';
		
	var code = document.getElementById('security_code').value;
	
	var kt = true ;
	kt = ktuser();
	if (ktuser()==true)
		var loiuser = document.getElementById("loitendangnhap").innerHTML = "";

	if(  matkhau1=="" )
	{
		document.getElementById("loimatkhau").innerHTML = "<img src=images/NotOk.gif>";
		kt =false ;
	}else if(  matkhau1.length < 6 )
	{
		document.getElementById("loimatkhau").innerHTML = "<img src=images/NotOk.gif>";
		kt =false ;
	}
	if(matkhau1 != matkhau2 )
	{
		document.getElementById("loairematkhau").innerHTML = "<img src=images/NotOk.gif>";
		kt =false ;
	}
	if(  email1 == "" )
	{
		document.getElementById("loiemail").innerHTML = "<img src=images/NotOk.gif>";
		kt =false ;
	}
	else if(checkEmail(email1) == 0)
	{
		document.getElementById("loiemail").innerHTML = "<img src=images/NotOk.gif>";
		kt =false ;
	}
	if(email1 != email2 )
	{
		document.getElementById("loireemail").innerHTML = "<img src=images/NotOk.gif>";
		kt =false ;
	}
	if ( hoten == "" )
	{
		document.getElementById("loihoten").innerHTML = "<img src=images/NotOk.gif>";
		kt =false ;
	}

	if( code == "" )
	{	
		var kq = document.getElementById("ErrorCode");
		kq.innerHTML = "<img src=images/NotOk.gif>";
		kt =  false;
	}
	
	if(kt == false)
		return false;
	
	var url ="index.php?com=user&fun=register&tendangnhap="+tendangnhap;
				url += "&email="+email1 ;
				url += "&matkhau="+matkhau1 ;
				url += "&hoten="+hoten ;
				url += "&ngay="+ngay;
				url += "&thang="+thang;
				url += "&nam="+nam;
				url += "&diachi="+diachi ;
				url += "&dienthoai="+dienthoai ;
				url += "&gioitinh="+gioitinh ;
				url += "&hinhanh="+hinhanh ;
				url += "&code="+code ;IDsLinhvuc
				url += "&IDsKhoa="+IDsLinhvuc ;
				url += "&Type=1";
				url += "&t="+ Math.random();
	document.location.href = url;
}

//---------update---------/

function XuLyCapNhatCSDLUser(ID)
{
	var hotenCu = encodeURI(document.getElementById("HoTenCu").value);
	var hotenMoi = encodeURI(document.getElementById("upHoTen").value);
	
	var index1 = document.getElementById("ngay").value;
	var index2 = document.getElementById("thang").value;
	var index3 = document.getElementById("nam").value;
	var ngaysinh = index3 +"-"+ index2 +"-"+index1 ;
	
	var diachiCu = encodeURI(document.getElementById("DiaChiCu").value);
	var diachiMoi = encodeURI(document.getElementById("upDiaChi").value);
	
	var dienthoaiCu = encodeURI(document.getElementById("DienThoaiCu").value);
	var dienthoaiMoi = encodeURI(document.getElementById("upDienThoai").value);
	
	
	var checkgioitinh = document.getElementById("upGioiTinh").checked;
	
	var hinhanhCu = encodeURI(document.getElementById("HinhAnhCu").value);
	var hinhanhMoi = encodeURI(document.getElementById("upHinhAnh").value);
	
	var kt = true ;
	
	if ( hotenMoi == "" )
		var hoten = hotenCu;
	else
		var hoten = hotenMoi;
				
	if (diachiMoi  == "" )
		var diachi = diachiCu;
	else
		var diachi = diachiMoi;
	
	if ( dienthoaiMoi == "" )
	{
		var dienthoai = dienthoaiCu;
		document.getElementById("loidienthoai").innerHTML ="" ;
	}
	else if(isNaN(dienthoaiMoi))
	{
		document.getElementById("loidienthoai").style.color = "red";
		document.getElementById("loidienthoai").innerHTML ="Không được nhập chữ" ;
		kt =false ;
	}else{
		var dienthoai = dienthoaiMoi;
		document.getElementById("loidienthoai").innerHTML ="" ;
	}
		
	if ( hinhanhMoi == "" )
	{
	//	alert (hinhanhCu);
		var hinhanh = hinhanhCu;
		var doihinh = 0;
	}
	else 
	{
		var hinhanh = hinhanhMoi;
		var doihinh = 1;
	}
			
	if(checkgioitinh == true)
		var gioitinh = 1;
	else
		var gioitinh = 0;	

	if(kt == true)
	{
		var url ="index.php?com=user&fun=updatethongtin&mauser="+ID;
			url += "&hoten="+hoten ;
			url += "&ngaysinh="+ngaysinh;
			url += "&diachi="+diachi ;
			url += "&dienthoai="+dienthoai ;
			url += "&gioitinh="+gioitinh ;
			url += "&hinhanh="+hinhanh ;
			url += "&doihinh="+doihinh ;
			url += "&Type=1";
			url += "&t="+ Math.random();

		document.location.href = url;
	}
	
}

function UpdateTaiKhoanUser(ID)
{
	var pass = encodeURI(document.getElementById("upPass").value);
	var passnew = encodeURI(document.getElementById("upPassNew").value);
	var repassnew = document.getElementById("upRePassNew").value;
	var code = document.getElementById("security_code").value;
	
	var loi = document.getElementById("loiupdate");
	loi.style.color = "red";
	var kt = true ;
	
	if ( pass == "" )
	{
		loi.innerHTML = "&nbsp;Chưa Nhập Mật khẩu củ"  ;
		return false;
	}
				
	if (passnew  == "" )
	{
		loi.innerHTML = "&nbsp;Chưa Nhập Mật khẩu mới"  ;
		return false;
	}
	if (passnew.length < 4 )
	{
		loi.innerHTML = "&nbsp;Mật khẩu phải nhiều hơn 4 ký tự"  ;
		return false;
	}
	
	if (repassnew == "" )
	{
		loi.innerHTML = "&nbsp;Chưa Nhập xác nhận Mật khẩu mới"  ;
		return false;
	}
	if(passnew != repassnew)
	{
		loi.innerHTML = "&nbsp;Xác Nhận Mật Khẩu không khóp"  ;
		return false;
	}
	
	
	var url ="index.php?com=user&fun=updatepass&ma="+ID;
		url += "&pass="+pass ;
		url += "&passnew="+passnew;
		url += "&code="+code ;
		url += "&Type=1";

	document.location.href = url;
	
}

//-------------- quen pass ------------------------
function kiemtralaypassemail()
{
	var email =  encodeURI(document.getElementById("passemail").value);
	if(  email == "" )
	{
		document.getElementById("loiemail").innerHTML = "Chưa nhập mail !!!";
		return false ;
	}
	if(checkEmail(email) == 0)
	{
		document.getElementById("loiemail").innerHTML = "Email không đúng định dạng!!!";
		return false ;
	}
	
	var url ="index.php?com=user&fun=quenpass";
				url += "&email="+email;
				url += "&Type=1";
	document.location.href = url;
}
/*--------------------End-Phat-------------------*/

function showResult()
{
	if (xmlhttp.readyState==4 && xmlhttp.status == 200)
	{
		document.getElementById("entry").innerHTML=xmlhttp.responseText;
	}
}

</script>
<?php
	if(!isset($_SESSION["Username"]))
	{	
       header("Location:index.php?com=user&fun=login&user=&pass=&remember=&Error=0&mess=0");
	}
	
	//--------------------------------------------//
	define ("MAX_SIZE","1024"); 

	function getExtension($str) {
		 $i = strrpos($str,".");
		 if (!$i) { return ""; }
		 $l = strlen($str) - $i;
		 $ext = substr($str,$i+1,$l);
		 return $ext;
	}
	
	$errors=1;
	
	if(isset($_FILES["upHinhAnh"]["error"])) 
	{
		
		$image=$_FILES["upHinhAnh"]["error"];
		
		if ($image) 
		{
			$filename = stripslashes($_POST['upHinhAnh']);
			$extension = getExtension($filename);
			$extension = strtolower($extension);
		
			if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
			{
				echo '<h1>Không phải file ảnh (các file có hổ trợ: *.jpg,*.jpeg,*.png,*.gif)!</h1>';
				$errors=1;
			}
			else
			{
				$size=filesize($_FILES["upHinhAnh"]["size"]);
	
				if ($size > MAX_SIZE*1024)
				{
					echo '<h1>Kích thước quá lớn (size file < 1MB)!</h1>';
					$errors=1;
				}else
				{
				move_uploaded_file($_FILES["upHinhAnh"]["tmp_name"],
      				"../images/nguoimua/" . $_FILES["upHinhAnh"]["name"]);
      				//echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
					//move_uploaded_file($_FILES["upHinhAnh"]["tmp_name"],"../images/nguoimua/" . $_FILES["upHinhAnh"]["name"]);
				//$hinhanh = $_FILES['upHinhAnh']['name'] ;
				//echo 'Stored in: ' . '../data/pic_ebook/' . $_FILES['image']['name'];
				$errors = 0;
				
				}
				
			}
		}
		else
		{
				$flag = 0 ;
				$errors = 1;
				$smg_img = 'Lỗi khi upload file hình ảnh !';
		}
	}
	if(isset($_POST['Submit']) && !$errors) 
	{
		echo "<h3 align='left' style='color:Blue'>Uploaded ảnh thành công</h3>";
	}

	//--------------------------------------------//
	
	function CapNhatVaoCSDL()
	{
		$mauser = $_REQUEST['mauser'];
		$hoten = $_REQUEST['hoten'];
		$ngaysinh = $_REQUEST['ngaysinh'];		
		$diachi = $_REQUEST['diachi'];
		$dienthoai = $_REQUEST['dienthoai'];
		$gioitinh = $_REQUEST['gioitinh'];
		$hinhanh = $_REQUEST['hinhanh'];
		$doihinh = $_REQUEST['doihinh'];
		$hinhanh="../images/nguoimua/".$hinhanh;
		/*
		if($doihinh == 1)
		{
			$hinhanh = "images/thanhvien/".$hinhanh;
			$hinhanh = $hinhanh;
		}
	*/
	//	echo $email;
		
		
		$tv = new XuLy_User();
		$tb = $tv->capnhat($mauser,$hoten,$ngaysinh,$diachi,$dienthoai,$gioitinh,$hinhanh);
		
		//echo $tb;
		if($tb == true)
			echo "<meta http-equiv=refresh content='0; url=index.php?com=user&fun=updatethongtin&mauser=$mauser&mess=1'/>";
		else
			echo "<meta http-equiv=refresh content='0; url=index.php?com=user&fun=updatethongtin&mauser=$mauser&mess=2'/>";
			
	}
?>

<?php																																					    include_once('components/user/class_user.php');
	
	$Type = 0;
	
	if(isset($_REQUEST['Type']))
		$Type = $_REQUEST['Type'];
	if ($Type == 1)
		CapNhatVaoCSDL();
	
	HienThiChiTiet();	
	
	
	function HienThiChiTiet()
	{
		$Mess = 0;
		$smg = '';
//		echo $Mess;
		if(isset($_REQUEST['mess']))
			$Mess = $_REQUEST['mess'];
		if ($Mess == 1)
			$smg = "<h3 align='left' style='color:Blue'>Cập Nhật Thành Công</h3>";
		if ($Mess == 2)
			$smg = "<h3 align='left' style='color:Red'>Cập Nhật Thất Bại</h3>";
			
		$tv = new XuLy_User();
		$row = $tv->chitiet($_SESSION['MaUser']);
	
		$mauser = $row['MaSo'];
		$tendangnhap= $row['Username'];
		$matkhaucu = $row['Password'];
		$email= $row['Email'];
		$hoten = $row['HoTen'];
		$diachi = $row['DiaChi'];
		$dienthoai = $row['DienThoai'];		
		$gioitinh = $row['GioiTinh'];
		$ngaysinh = $row['NgaySinh'];
		$hinhanh = $row['HinhAnh'];
		$hinhanh="../images/nguoimua/".$hinhanh;
		if(!@file_get_contents($hinhanh))
			$hinhanh = '../images/nguoimua/nopic.gif';
		//	$hinhanh = 'images/thanhvien/nopic2.gif';
		$nam = substr($ngaysinh,0,4);
		$thang = substr($ngaysinh,5,2);
		$ngay = substr($ngaysinh,8);
	
		echo '<form name="form1" id="form1" method="post"><table width="800px" border="0" cellpadding="0px" cellspacing="0px">
		    <tr>
			<td width="1%" height="29" style="background:url(images/bar_left.gif);background-repeat:no-repeat"></td>
			<td width="99%" style="background-image:url(images/bar_mid.gif);background-repeat:repeat-x">
			<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
			<td width="3%" height="24"><img src="images/bullet_next.png" width="13" height="12" /></td>
			<td width="51%" style="color:#A;font-size:22px;font-weight:bold;">CẬP NHẬT TÀI KHOẢN</td>
			 <td width="23%" align="right">
			</td>
			<td align="right" width="23%" style="color:#FFF;padding-right:10px;">
			</td>
			</tr></table>    
			</td>
		  </tr>
		  <tr>
			<td colspan="2" style="color:red" align="center">
			 '.$smg.'
			</td>
			</tr>
		<tr>
			<td colspan="2" align="center">';		
	
		echo "<h3> ----- Thông Tin Tài Khoản ----- </h3>";
		echo "<table class='sample'>
			  <tr>
				<td rowspan='7' ><img src=$hinhanh width='100' height='150' align='middle'></td>
				<td>Họ tên</td>
				<td><input id='HoTenCu' name='HoTenCu' type='hidden' value='$hoten'/>
				<input id='upHoTen' name='upHoTen' type='text' value='$hoten'/></td>
				<td>&nbsp;</td>
			  </tr>
			  <tr>
				<td>Địa Chỉ</td>
				<td><input id='DiaChiCu' name='DiaChiCu' type='hidden' value='$diachi'/>
				<input id='upDiaChi' name='upDiaChi' type='text' value='$diachi'/></td>
				<td>&nbsp;</td>
			  </tr>		  
			 <tr>
				<td>Điện Thoại</td>
				<td><input id='DienThoaiCu' name='DienThoaiCu' type='hidden' value='$dienthoai'/>
				<input id='upDienThoai' name='upDienThoai' type='text' value='$dienthoai'/></td>
				<td><div id='loidienthoai'></div></td>
			  </tr>
			   <tr>
				<td>Giới tính</td>";
				if($gioitinh == 1)
				{
					echo "<td><input id='upGioiTinh' name='upGioiTinh' type='radio' checked='checked' value='Nam'/>Nam &nbsp;
					<input id='upGioiTinh' name='upGioiTinh' type='radio' value='Nu'/>	Nữ</td> ";
				}
				else
				{
					echo "<td><input id='upGioiTinh' name='upGioiTinh' type='radio' value='Nam'/>Nam &nbsp;
					<input id='upGioiTinh' name='upGioiTinh' type='radio' checked='checked' value='Nu'/>Nữ</td> ";
				}
			echo "
				<td>&nbsp;</td>
			  </tr>
			   <tr>
				<td>Ngày sinh</td>
				<td>
					<select name='ngay' id='ngay' >";
						for($i = 1 ; $i<=31 ; $i++)
						{
							if($ngay == $i )
								echo "<option value='$i' selected='selected'>$i</option>";
							else
								echo "<option value='$i'>$i</option>";
						}
					echo "</select>";
					echo "&nbsp;&nbsp;";
					echo "<select name='thang' id='thang' >";
						for( $i = 1 ; $i<=12 ; $i++)
						{
							if($thang == $i )
								echo "<option value='$i' selected='selected'>$i</option>";
							else
								echo "<option value='$i'>$i</option>";
						}					
					echo "</select>";
					echo "&nbsp;&nbsp;";
					echo "<select name='nam' id='nam' >";	
						for($i = date('Y') ; $i>1929 ; $i--)
						{
							if($nam == $i )
								echo "<option value='$i' selected='selected'>$i</option>";
							else
								echo "<option value='$i'>$i</option>";
						}					
					echo "</select>";
				echo "
				</td>
				<td>&nbsp;</td>
			  </tr>
			  <tr>
				<td>Hình Ảnh</td>
				<form name='newad' method='post' enctype='multipart/form-data'  action=''>
				<td><input id='HinhAnhCu' name='HinhAnhCu' type='hidden' value='$hinhanh'/>
				<input id='upHinhAnh' name='upHinhAnh' type='file' value='$hinhanh'/>
				<input name='Submit' type='submit' value='Upload image'>
				</td>
				</form>
				<td>&nbsp;</td>
			  </tr>
			</table>";	
			echo "<br />";
		echo "<input type='button' name='Update' value='Cập nhật' onclick='XuLyCapNhatCSDLUser($mauser)'>";
	}
?>
	<?php 
		echo '</td></tr></table></form>' ;
	?>
	<div style="height:50px;width:100%" align="center">&nbsp;</div>